<template>
	<view class="count">
		<view @click="bigSmall" class="top f f-a-c f-j-c f-d-c">
			<image src="/static/zuan.png" class="drill" mode=""></image>
			<view class="bigSmall">
				扫码借阅
			</view>
		</view>
		<view @click="startOfBudget" class="bot f f-a-c f-j-c f-d-c">
			<image src="/static/lvjing.png" class="drill" mode=""></image>
			<view class="bigSmall">
				手动借阅
			</view>
		</view>
		<u-popup mode="center" width="80%" border-radius="25" v-model="show">
			<view class="body p-t-30">
				<view class="topTit m-b-40">
					手动借阅
				</view>
				<input type="text" v-model="value" class="inp" placeholder="请输入书籍编号" name="" id="">
				<view class="xian">

				</view>
				<view class="boxF f f-a-c">
					<view @click="show=false" class="quxiao f f-a-c f-j-c">
						取消
					</view>
					<view @click="givmi" class="comig f f-a-c f-j-c">
						确认
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				value: ''
			}
		},
		methods: {
			// 点击去借阅确认页
			async givmi() {
				if (this.value.length == 0) return this.$msg('请输入编号')
				let n = await this.$api.BorrowsConfirm({
					book_no: this.value
				})
				this.show = false
				if (n.status) {
					// /如果能通过就跳转
					uni.navigateTo({
						url: '/pages/index/ConfirmationPage?code=' + this.value
					})
				} else {
					this.$msg(n.message)
				}

			},
			// 扫码借阅
			bigSmall() {
				uni.scanCode({
					success: async (res) => {
						// console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						let n = await this.$api.BorrowsConfirm({
							book_no: res.result
						})
						// this.$msg(n.message)
						if (n.status) {
							// /如果能通过就跳转
							uni.navigateTo({
								url: '/pages/index/ConfirmationPage?code=' + res.result
							})
						} else {
							this.$msg(n.message)
						}
					}
				});
				// uni.navigateTo({
				// 	url: '/pages/index/drillingSelection'
				// })
			},
			// 手动借阅
			startOfBudget() {
				this.show = true
				// uni.navigateTo({
				// 	url: '/pages/index/drillingBudget'
				// })
			}
		}
	}
</script>

<style lang="scss" scoped>
	.boxF {
		height: 88rpx;
	}

	.quxiao {
		width: 50%;
		height: 100%;
		border-right: 2rpx solid #b8b8bb;
		font-size: 30rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		text-align: center;
		color: #666666;
	}

	.comig {
		width: 50%;
		height: 100%;
		font-size: 30rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;
		color: #009d85;
	}

	.body {
		.xian {
			width: 100%;
			height: 2rpx;
			background: #b8b8bb;
			margin-top: 50rpx;
		}

		.inp {
			width: 90%;
			height: 80rpx;
			background: #ffffff;
			border: 2rpx solid #dedede;
			border-radius: 12rpx;
			padding-left: 20rpx;
			margin: 0 auto;
			// margin: 40rpx 0;
		}

		.topTit {
			font-size: 32rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
			text-align: center;
			color: #333333;
		}
	}

	.top {
		height: 45%;
		width: 100%;
		border-radius: 40rpx;
		margin-bottom: 4%;
		background-color: #f3f9ff;


		.drill {
			width: 106rpx;
			height: 106rpx;
		}

		.bigSmall {
			font-size: 30rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
			color: #009D85;
			margin-top: 15rpx;
		}
	}

	.bot {
		height: 45%;
		width: 100%;
		border-radius: 40rpx;
		background: #fef8f3;

		.drill {
			width: 90rpx;
			height: 98rpx;
		}

		.bigSmall {
			font-size: 30rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
			color: #FABE00;
			margin-top: 15rpx;
		}
	}

	.count {
		height: 100vh;
		width: 100%;
		background-color: #fff;
		padding: 30rpx;
	}
</style>